#include<iostream>
#include<map>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
LL a[N];
LL s1[N], s2[N];
map<LL, int>mp1, mp2;
int n;
int main()
{
	int t;
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		for (int i = 0; i <= n + 1; i++) {
			s1[i] = 0, s2[i] = 0;
		}
		mp1.clear();
		mp2.clear();
		for (int i = 1; i <= n; i++) {
			scanf("%lld", &a[i]);
			s1[i] = s1[i - 1] + a[i];
			mp1[s1[i]] = i;
		}
		for (int i = n; i >= 1; i--) {
			s2[i] = s2[i + 1] + a[i];
			mp2[s2[i]] = i;
		}
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			LL x = s1[i];
			//cout << "x==" << x << endl;
			if (mp2[x]) {
				if (mp2[x] > i) {
					//cout << "mp2[x]==" << mp2[x] << endl;
					//cout << "i==" << i << endl;
					ans = max(ans, i + n - mp2[x] + 1);
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}